package com.lancoo.znbkxx.teacher.adapter

import android.net.Uri
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.luck.picture.lib.entity.LocalMedia
import kotlinx.android.synthetic.main.item_image.view.*

/**
 * @author : wealive
 * @date   : 2020/3/19 8:58
 * @desc   :
 */
class StuImageAdapter(layoutResId: Int, data: MutableList<LocalMedia>) :
        BaseQuickAdapter<LocalMedia, BaseViewHolder>(layoutResId, data) {
    override fun convert(helper: BaseViewHolder, item: LocalMedia?) {
        with(helper.itemView) {
            val downLoadUrl =
                    if (item!!.path.contains("storage")) "file://$item.path" else item.path
//            val controllerListener =
//                Fresco.newDraweeControllerBuilder().setControllerListener(object :
//                    BaseControllerListener<ImageInfo>() {
//                    override fun onFinalImageSet(
//                        id: String?,
//                        imageInfo: ImageInfo?,
//                        animatable: Animatable?
//                    ) {
//                        val params =
//                            sdv.layoutParams
//                        params.height = DensityUtils.dp2px(context, 100f)
//                        params.width =
//                            ((imageInfo!!.width.toFloat() / imageInfo.height * DensityUtils.dp2px(
//                                context,
//                                100f
//                            )).toInt())
//                        sdv.layoutParams = params
//                    }
//                }).setUri(Uri.parse(downLoadUrl)).build()
//            sdv.controller = controllerListener
            sdv.setImageURI(Uri.parse(downLoadUrl), context)
        }
    }
}